From b46d79c8792cd5de9aded0c83956cd5ac76f8697 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 13 Nov 2025 11:46:51 +0100 Subject: [PATCH] odhcp6c: properly guard attributes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Properly guard odhcp6c.h attributes with `#ifndef` to avoid redefining them when including external headers. Also convert the remaining __attribute__ usages to the custom declarations. Signed-off-by: Álvaro Fernández Rojas Link: https://github.com/openwrt/odhcp6c/pull/120 --- src/odhcp6c.h | 14 +++++++++++--- src/ra.c | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/odhcp6c.h b/src/odhcp6c.h index 6c669c0..02578cc 100644 --- a/src/odhcp6c.h +++ b/src/odhcp6c.h @@ -20,9 +20,17 @@ #include #include -#define _o_unused __attribute__((unused)) -#define _o_packed __attribute__((packed)) +#ifndef _o_aligned #define _o_aligned(n) __attribute__((aligned(n))) +#endif /* _o_aligned */ + +#ifndef _o_packed +#define _o_packed __attribute__((packed)) +#endif /* _o_packed */ + +#ifndef _o_unused +#define _o_unused __attribute__((unused)) +#endif /* _o_unused */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -278,7 +286,7 @@ struct dhcpv6_retx { struct dhcpv6_header { uint8_t msg_type; uint8_t tr_id[3]; -} __attribute__((packed)); +} _o_packed; struct dhcpv6_ia_hdr { uint16_t type; diff --git a/src/ra.c b/src/ra.c index ffff0aa..dcc5fd6 100644 --- a/src/ra.c +++ b/src/ra.c @@ -71,7 +71,7 @@ struct { .lladdr = {ND_OPT_SOURCE_LINKADDR, 1, {0}}, }; -static void ra_send_rs(int signal __attribute__((unused))); +static void ra_send_rs(_o_unused int signal); int ra_init(const char *ifname, const struct in6_addr *ifid, unsigned int options, unsigned int holdoff_interval) @@ -189,7 +189,7 @@ failure: return -1; } -static void ra_send_rs(int signal __attribute__((unused))) +static void ra_send_rs(_o_unused int signal) { const struct sockaddr_in6 dest = {AF_INET6, 0, 0, ALL_IPV6_ROUTERS, if_index}; const struct icmpv6_opt llnull = {ND_OPT_SOURCE_LINKADDR, 1, {0}}; -- 2.30.2